// GroupAI.h: interface for the CGroupAI class.
// Dont modify this file
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GroupAI_H__10718E36_5CDF_4CD4_8D90_F41311DD2694__INCLUDED_)
#define AFX_GroupAI_H__10718E36_5CDF_4CD4_8D90_F41311DD2694__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ExternalAI/IGlobalAI.h"
#include "ExternalAI/IGlobalAICallback.h"
#include "ExternalAI/IAICallback.h"

#include "MetalMap.h"
#include "HeightMap.h"
#include <ctime>
#include <vector>
typedef unsigned char uchar;

#include <map>
#include <set>
#include <list>
#include <queue>
const float3 NIGDZIE = float3(-1,0,0);
#include "globalne.h"

using namespace std;

template <typename T> class noli;
template <typename T> class wezelek;
class TTAICore;
class MetalMap;
class Prokop;
class UnitHandler;
class reshandler;
class forcehandler;
class UnitTable;
class baza;
class oddzial;
class mozg;
class TTAICore;
extern TTAICore * C;
template <typename T>  std::vector<T> & przepisz(std::vector<T> & wektorek, std::set<T> & secik)
{
	for (typename std::set<T>::iterator it=secik.begin();it!=secik.end();it++)
	{
		wektorek.push_back(*it);
	}
	return wektorek;
};
class TTAICore : public IGlobalAI
{
public:
	TTAICore();
	virtual ~TTAICore();
    MetalMap *mt;
    Prokop *pr;
    //UnitHandler *uh;
    //reshandler *rh;
    //UnitTable *ut;
    Globalne *gl; //pointer to object with streams for logs
	mozg *M; //pointer to AI's brain (there are important functions, some of them make "beeep")
	//Polikarp *P; //pointer to map analyser, for future version
	Polikarp * P1;//HeightMap for units with small slopeTolerance (x<=P->dajSlopeTol(2)/1.25)
	Polikarp * P2;//HeightMap for units with medium slopeTolerance (P->dajSlopeTol(2)/1.25 <x< P->dajSlopeTol(8)/1.25)
	Polikarp * P3;//HeightMap for units with big slopeTolerance (x>=P->dajSlopeTol(8)/1.25), here are also precalculated distances to coast
	Polikarp * Ph;//HeightMap for hovercrafts
	string sciezka;
	time_t start;
	char tuSaLogi[200]; //path to file with logs
	bool ratujLogi; //if true, logs won't be deleted

    void Global(IGlobalAICallback* callback);
	void InitAI(IGlobalAICallback* callback, int team);

	void UnitCreated(int unit);									//called when a new unit is created on ai team
	void UnitFinished(int unit);								//called when an unit has finished building
	void UnitDestroyed(int unit,int attacker);								//called when a unit is destroyed

	void EnemyEnterLOS(int enemy);
	void EnemyLeaveLOS(int enemy);

	void EnemyEnterRadar(int enemy);
	void strzalkuj (float3 p, float3 q, float grubosc=10, float strzala=20,
		int czas=600, int grupa=1);

	void EnemyLeaveRadar(int enemy);

	void EnemyDamaged(int a, int b, float c, float3 d);
	void EnemyDestroyed(int enemy,int attacker);							//will be called if an enemy inside los or radar dies (note that leave los etc will not be called then)

	void UnitIdle(int unit);										//called when a unit go idle and is not assigned to any group

	void GotChatMsg(const char* msg,int player);					//called when someone writes a chat msg

	void UnitDamaged(int damaged,int attacker,float damage,float3 dir);					//called when one of your units are damaged
	void UnitMoveFailed(int unit);
	int HandleEvent (int msg,const void *data);
	void Update(); //called every frame

	IGlobalAICallback* callback;
	IAICallback *cb;

	bool jestTrochuWody;
	int dgun;
	float wiatr; //averege wind strenght
	bool wiatr_rob; //should we build windmills? or not?
	vector<baza*> bazy; //bases, currently not fully supported (there is onlu one base)
	baza* glowna; //pointer to main base
    void InicZm(); //sth like InitAI, but in another function. Don't ask me why.
    int width,height; //proportions of map, that used for moving units or most othre things
    static vector<int> SpotState; //for metalMap, the rest is in name
	//set<int> myUnits;
	//set<int> enemies;
};
#endif